import { _decorator, Component, Node, Camera } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('MiniMapAutoHeight')
export class MiniMapAutoHeight extends Component {

    @property(Node) planeNode: Node
    @property(Node) topNode: Node
    @property(Node) playerNode: Node

    start() {

    }

    update(deltaTime: number) {
        const height = this.planeNode.getScale().y * this.topNode.getPosition().y
        this.node.setPosition(0, height, 0)
        this.node.getComponent(Camera).far = height * 2
        this.node.getComponent(Camera).orthoHeight = Math.ceil(this.playerNode.getScale().x / 10) * 340
    }
}


